package com.example.shop.mapper;

import com.example.shop.entity.GoodsSku;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/9/2 21:41
 **/
@Mapper
public interface GoodsSkuMapper {
    @Insert("""
INSERT INTO mi_goods_sku (sku_id, goods_id, attr, cover_image_id, 
create_time, update_time, operator_id, is_delete) 
VALUES (#{skuId}, #{goodsId}, #{attr}, #{coverImageId}, now(), now(), null, 0);
""")
    void saveGoodsSku(GoodsSku goodsSku);

    @Select("""
select * from mi_goods_sku where goods_id = #{goodsId};
""")
    List<GoodsSku> queryGoodsSkuByGoodsId(String goodsId);

    @Select("""
select * from mi_goods_sku where goods_id = #{goodsId} and sku_id = #{skuId};
""")
    GoodsSku queryGoodsSkuByGoodsIdWithSkuId(@Param("goodsId") String goodsId,
                                                   @Param("skuId") String skuId);
}
